import pyglet


# 顶点着色器
vertex_shader = """
    #version 120
    void main() {
        gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
        gl_TexCoord[0] = gl_MultiTexCoord0;
        gl_FrontColor = gl_Color;
    }
"""

# 全黑片段着色器
fragment_shader_black = """
    #version 120
    uniform sampler2D texture;
    void main() {
        vec4 color = texture2D(texture, gl_TexCoord[0].st);
        float gray = 0.0; // 全黑
        gl_FragColor = vec4(gray, gray, gray, color.a);
    }
"""

# 全白片段着色器
fragment_shader_white = """
    #version 120
    uniform sampler2D texture;
    void main() {
        vec4 color = texture2D(texture, gl_TexCoord[0].st);
        float gray = 1.0; // 全白
        gl_FragColor = vec4(gray, gray, gray, color.a);
    }
"""


# 编译着色器
shader = pyglet.graphics.shader.ShaderProgram(
    pyglet.graphics.shader.Shader(vertex_shader, "vertex"),
    pyglet.graphics.shader.Shader(fragment_shader_black, "fragment")
)
